#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class people{
public:
	int id;
	string score;
};

bool operator<(people a,people b){
	if(a.score.size()<b.score.size())return true;
	if(a.score.size()>b.score.size())return false;
	if(a.score.size()==b.score.size()){
		for(int i=0;i<a.score.size();i++){
			if(a.score[i]<b.score[i])return true;
			if(a.score[i]>b.score[i])return false;
			if(a.score[i]==b.score[i])continue;
		}
	}
	return false;
}
int main(void){
	people max;
	people input;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>input.score;
		input.id=i;
		if(max<input)max=input;
	}
	cout<<max.id<<endl<<max.score;
	return 0;
}

